home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Mail / Sources / UMailerView.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  22.7 KB  |  733 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UMailerView.cp
  3. // Copyright © 1988-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6.  
  7. #if qPowerTalk
  8.  
  9. #ifndef __UMAILERVIEW__
  10. #include "UMailerView.h"
  11. #endif
  12.  
  13. // MacApp
  14.  
  15. #ifndef __UCLIPBOARDMGR__
  16. #include "UClipboardMgr.h"
  17. #endif
  18.  
  19. #ifndef __UDISPATCHER__
  20. #include "UDispatcher.h"
  21. #endif
  22.  
  23. #ifndef __UMAILER__
  24. #include "UMailer.h"
  25. #endif
  26.  
  27. #ifndef __UMACAPPGLOBALS__
  28. #include "UMacAppGlobals.h"
  29. #endif
  30.  
  31. #ifndef __UMACAPPUTILITIES__
  32. #include "UMacAppUtilities.h"
  33. #endif
  34.  
  35. #ifndef __UMAILABLE__
  36. #include "UMailable.h"
  37. #endif
  38.  
  39. #ifndef __UMENUMGR__
  40. #include "UMenuMgr.h"
  41. #endif
  42.  
  43. #ifndef __UWINDOW__
  44. #include "UWindow.h"
  45. #endif
  46.  
  47. //    #ifndef __UAPPLICATION__
  48. //    #include "UApplication.h"
  49. //    #endif
  50.  
  51. // Toolbox
  52.  
  53. #ifndef __AEREGISTRY__
  54. #include <AERegistry.h>
  55. #endif
  56.  
  57. #ifndef __FOLDERS__
  58. #include <Folders.h>
  59. #endif
  60.  
  61. #ifndef    __OCEERRORS__
  62. #include <OCEErrors.h>
  63. #endif
  64.  
  65. #ifndef __OCESTANDARDDIRECTORY__
  66. #include <OCEStandardDirectory.h>
  67. #endif
  68.  
  69. //========================================================================================
  70. // GLOBAL Functions
  71. //========================================================================================
  72.  
  73. PrepareMailerForDrawingUPP gMacAppPrepareMailerForDrawingProc;
  74. FrontWindowUPP gFrontWindowUPP;
  75.  
  76. //----------------------------------------------------------------------------------------
  77. // Prototypes for local functions
  78. //----------------------------------------------------------------------------------------
  79.  
  80. pascal void MacAppPrepareMailerForDrawingProc(WindowRef window, long clientData);
  81. pascal WindowRef MyFrontWindowProc(long data);
  82.  
  83. //----------------------------------------------------------------------------------------
  84. // MacAppPrepareMailerForDrawingProc
  85. //----------------------------------------------------------------------------------------
  86. #pragma segment AMailerRes
  87.  
  88. pascal void MacAppPrepareMailerForDrawingProc(WindowRef /* window */,
  89.                                               long clientData)
  90. {
  91.     TView* theMailerView = (TView *)clientData;
  92.     theMailerView->Focus();
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // MyFrontWindowProc
  97. //----------------------------------------------------------------------------------------
  98. #pragma segment AMailerRes
  99.  
  100. pascal WindowRef MyFrontWindowProc(long /* clientData */)
  101. {
  102.     // PowerTalk 1.1 is supposed to set A5 but doesn't.
  103. #if qSegments
  104.     // Set and restore A5 for compatibility with AOCE
  105.     long A5RegisterOnEntry = SetCurrentA5();
  106. #endif
  107.     WindowRef frontWindow = NULL;
  108.     {
  109.         frontWindow = TWindow::MAFrontWindow();
  110.     }
  111. #if qSegments
  112.     SetA5(A5RegisterOnEntry);
  113. #endif
  114.     return frontWindow;
  115. }
  116.  
  117. //----------------------------------------------------------------------------------------
  118. // InitUMailerView
  119. //----------------------------------------------------------------------------------------
  120. #pragma segment AInit
  121.  
  122. void InitUMailerView()
  123. {
  124.     if (!HasAOCEToolBox())
  125.     {
  126. #if qDebug
  127.         ProgramBreak("InitUMailerView called but AOCE isn't present.");
  128. #endif
  129.         return;
  130.     }
  131.     
  132.     FailNIL(gMacAppPrepareMailerForDrawingProc = NewPrepareMailerForDrawingProc(&MacAppPrepareMailerForDrawingProc));
  133.     FailNIL(gFrontWindowUPP = NewFrontWindowProc(&MyFrontWindowProc));
  134. }
  135.  
  136. //========================================================================================
  137. // CLASS TMailerView
  138. //========================================================================================
  139. #undef Inherited
  140. #define Inherited TView
  141.  
  142. #pragma segment AOCEMailerRes
  143. MA_DEFINE_CLASS_M1(TMailerView, Inherited);
  144.  
  145. //----------------------------------------------------------------------------------------
  146. // TMailerView::TMailerView
  147. //----------------------------------------------------------------------------------------
  148. #pragma segment ConstructorRes
  149.  
  150. TMailerView::TMailerView()
  151.     : fLetter(NULL),
  152.       fLastTargetField(kSMPRegarding),
  153.       fMailerExpanded(FALSE),
  154.       fMailerClosed(FALSE)
  155. {
  156.     fHandlesCursor = FALSE;
  157.     fLetsSubViewsHandleCursor = FALSE;
  158.     fWantsToBeTarget = FALSE;
  159. }
  160.  
  161. //----------------------------------------------------------------------------------------
  162. // TMailerView destructor
  163. //----------------------------------------------------------------------------------------
  164. #pragma segment MADestructorRes
  165.  
  166. TMailerView::~TMailerView()
  167. {
  168. }
  169.  
  170. //----------------------------------------------------------------------------------------
  171. // TMailerView::IMailerView
  172. //----------------------------------------------------------------------------------------
  173. #pragma segment AMailerRes
  174.  
  175. void TMailerView::IMailerView(TLetter* itsLetter,
  176.                               TView* itsSuperView,
  177.                               Boolean initiallyExpanded)
  178. {
  179.     // Initializes a mailer view but does not actually create a mailer.
  180.     
  181.     FailNonObject(itsLetter);
  182.     TDocument* itsDocument = itsLetter->fDocument;
  183.     
  184.     fLetter = itsLetter;
  185.     fIdentifier = kMailerViewID;
  186.  
  187.     CPoint dimensions = TMailerView::GetDimensions(initiallyExpanded);
  188.     
  189.     // size width up to size of superview
  190.     if (itsSuperView->fSize.h > dimensions.h)
  191.         dimensions.h = itsSuperView->fSize.h;
  192.             
  193.     VPoint theSize(dimensions);
  194.     this->IView(itsDocument, itsSuperView, gZeroVPt, theSize, sizeSuperView, sizeVariable);
  195. }
  196.  
  197. //----------------------------------------------------------------------------------------
  198. // TMailerView::OpenNewMailer : Creates a new mailer in the view.
  199. //----------------------------------------------------------------------------------------
  200. #pragma segment AMailerRes
  201.  
  202. void TMailerView::OpenNewMailer(Boolean initiallyExpanded,
  203.                                 Boolean canContract)
  204. {
  205.     GrafPtr thePort = this->GetGrafPort();
  206.     long     clientData = (long)this;
  207.  
  208.     FailOSErr(SMPNewMailer(thePort, gZeroPt, canContract, initiallyExpanded, 0, 
  209.         gMacAppPrepareMailerForDrawingProc, clientData));
  210.     fMailerExpanded = initiallyExpanded;
  211. }
  212.  
  213. //----------------------------------------------------------------------------------------
  214. // TMailerView::OpenOldMailer : Creates a mailer in the view for an existing letter.
  215. //----------------------------------------------------------------------------------------
  216. #pragma segment AMailerRes
  217.  
  218. void TMailerView::OpenOldMailer(LetterDescriptor theDesc,
  219.                                 Boolean initiallyExpanded,
  220.                                 Boolean canContract)
  221. {
  222.     GrafPtr         thePort = this->GetGrafPort();
  223.     long             clientData = (long)this;
  224.     AuthIdentity     localIdentity;
  225.     
  226.     // Don't allow user interaction when getting the local identity. It should
  227.     // be impossible to get here without a valid id being available.
  228.     if (gMailing->GetAOCEIdentity(localIdentity, FALSE) == noErr)
  229.     {
  230.         FailOSErr(SMPOpenLetter(&theDesc, thePort, gZeroPt, canContract, 
  231.             initiallyExpanded, gMacAppPrepareMailerForDrawingProc, clientData));
  232.         fMailerExpanded = initiallyExpanded;
  233.     }
  234. #if qDebug
  235.     else
  236.     {
  237.         ProgramBreak("TMailerView::OpenOldMailer unexpectedly couldn't get local identity.");
  238.     }
  239. #endif
  240. }
  241.  
  242. //----------------------------------------------------------------------------------------
  243. // TMailerView::OpenReplyMailer : Creates a mailer in the view in reply to an existing 
  244. // letter.
  245. //----------------------------------------------------------------------------------------
  246. #pragma segment AMailerRes
  247.  
  248. void TMailerView::OpenReplyMailer(WindowRef theReplyToWindow,
  249.                                   Boolean replyToAll,
  250.                                   Boolean initiallyExpanded,
  251.                                   Boolean canContract)
  252. {
  253.     GrafPtr         thePort = this->GetGrafPort();
  254.     CPoint             upperLeft(0, 0);
  255.     long             clientData = (long)this;
  256.     AuthIdentity     localIdentity;
  257.     
  258.     // Don't allow user interaction when getting the local identity. It should
  259.     // be impossible to get here without a valid id being available.
  260.     if (gMailing->GetAOCEIdentity(localIdentity, FALSE) == noErr)
  261.     {
  262.         FailOSErr(SMPMailerReply((WindowPtr)theReplyToWindow, thePort, replyToAll, upperLeft, 
  263.             canContract, initiallyExpanded, localIdentity, gMacAppPrepareMailerForDrawingProc, clientData));
  264.         fMailerExpanded = initiallyExpanded;
  265.     }
  266. #if qDebug
  267.     else
  268.     {
  269.         ProgramBreak("TMailerView::OpenReplyMailer unexpectedly couldn't get local identity.");
  270.     }
  271. #endif
  272. }
  273.  
  274. //----------------------------------------------------------------------------------------
  275. // TMailerView::Activate
  276. //----------------------------------------------------------------------------------------
  277. #pragma segment AMailerRes
  278.  
  279. void TMailerView::Activate(Boolean entering)
  280. {
  281.     // Feed the mail package an activate event.
  282.     EventRecord theEvent;
  283.     BlockSet((Ptr)&theEvent, sizeof(theEvent), 0);
  284.     theEvent.what = activateEvt;
  285.     theEvent.message = (long)this->GetWindow()->fWMgrWindow;
  286.     theEvent.modifiers = entering;
  287.     theEvent.when = TickCount();
  288.     OSErr err = 0;
  289.     SMPMailerResult whatHappened = 0;
  290.     err = SMPMailerEvent(&theEvent, &whatHappened, gFrontWindowUPP, (long)this);
  291.     Inherited::Activate(entering);
  292. }
  293.  
  294. //----------------------------------------------------------------------------------------
  295. // TMailerView::Close
  296. //----------------------------------------------------------------------------------------
  297. #pragma segment AMailerRes
  298.  
  299. void TMailerView::Close()
  300. {
  301.     {
  302.         WindowRef theWindow = this->GetWindow()->fWMgrWindow;
  303.         
  304.         if (fLetter->fLetterTabber)        // Remove the tabber
  305.         {
  306.             TWindow *mailerWindow = fLetter->GetMailerWindow();
  307.             mailerWindow->RemoveBehavior(fLetter->fLetterTabber);
  308.             fLetter->fLetterTabber = (TLetterTabber*)FreeIfObject(fLetter->fLetterTabber);
  309.         }
  310.         
  311.         //We should never fail here - see SMPPrepareToClose in 
  312.         //TMailableDocument::Close()
  313.         
  314.         FailOSErr(SMPDisposeMailer((WindowPtr)theWindow, NULL));
  315.         fMailerClosed = TRUE;
  316.     }
  317.     Inherited::Close();
  318. }
  319.  
  320. //----------------------------------------------------------------------------------------
  321. // TMailerView::Draw :    Tells the mail package to draw the mailer.
  322. //----------------------------------------------------------------------------------------
  323. #pragma segment AMailerRes
  324.  
  325. void TMailerView::Draw(const VRect& area)
  326. {
  327.     Inherited::Draw(area);
  328.     FailOSErr(SMPDrawMailer(this->GetGrafPort()));
  329. }
  330.  
  331. //----------------------------------------------------------------------------------------
  332. // TMailerView::BecameTarget :  Inform the mail package that the mailer view has been
  333. // targeted.
  334. //----------------------------------------------------------------------------------------
  335. #pragma segment AMailerRes
  336.  
  337. void TMailerView::BecameTarget()
  338. {
  339.     SMPMailerState     theMailerState;
  340.     WindowPtr         theWindowPtr = (WindowPtr)this->GetWindow()->fWMgrWindow;
  341.  
  342.     Inherited::BecameTarget();
  343.     
  344.     FailOSErr(SMPGetMailerState(theWindowPtr, &theMailerState));
  345.     
  346.     if (!theMailerState.isTarget && this->Focus())
  347.         FailOSErr(SMPBecomeTarget(theWindowPtr, TRUE, this->fLastTargetField));
  348.  
  349.     gClipboardMgr->AboutToLoseControl(TRUE);
  350. }
  351.  
  352. //----------------------------------------------------------------------------------------
  353. // TMailerView::ResignedTarget : Inform the mail package that the mailer view is no
  354. // longer the target.
  355. //----------------------------------------------------------------------------------------
  356. #pragma segment AMailerRes
  357.  
  358. void TMailerView::ResignedTarget()
  359. {
  360.     Inherited::ResignedTarget();
  361.     if (!fMailerClosed && this->Focus())
  362.     {
  363.         WindowPtr theWindowPtr = (WindowPtr)this->GetWindow()->fWMgrWindow;
  364.         SMPMailerState theMailerState;
  365.         
  366.         FailOSErr(SMPGetMailerState(theWindowPtr, &theMailerState));
  367.         
  368.         if (theMailerState.isTarget)
  369.         {
  370.             this->fWantsToBeTarget = FALSE;
  371.             FailOSErr(SMPBecomeTarget(theWindowPtr, FALSE, 0));
  372.             this->fLastTargetField = theMailerState.targetComponent;
  373.         }
  374.     }
  375.     gClipboardMgr->CheckDeskScrap();
  376. }
  377.  
  378. //----------------------------------------------------------------------------------------
  379. // TMailerView::ExpandMailer : Expands the mailer to its full size.
  380. //----------------------------------------------------------------------------------------
  381. #pragma segment AMailerRes
  382.  
  383. void TMailerView::ExpandMailer()
  384. {
  385.     if (this->Focus())
  386.     {
  387.         VRect oldFrame(this->GetFrame());
  388.         
  389.         CPoint dimensions = TMailerView::GetDimensions(kExpanded);
  390.         VRect newFrame(0, 0, oldFrame.right, dimensions.v);
  391.         this->SetFrame(newFrame, kDontInvalidate);
  392.         
  393.         OSErr err = SMPExpandOrContract(this->GetGrafPort(), kExpanded);
  394.         
  395.         // Move other views down
  396.         long vOffset = newFrame.GetLength(vSel) - oldFrame.GetLength(vSel);
  397.  
  398.         this->fMailerExpanded = TRUE;
  399.         fLetter->MakeRoomForMailer(vOffset, kRedraw);
  400.     }
  401. }
  402.  
  403. //----------------------------------------------------------------------------------------
  404. // TMailerView::ContractMailer : Shrinks the mailer to its contracted size.
  405. //----------------------------------------------------------------------------------------
  406. #pragma segment AMailerRes
  407.  
  408. void TMailerView::ContractMailer()
  409. {
  410.     if (this->Focus())
  411.     {
  412.         VRect oldFrame(this->GetFrame());
  413.         
  414.         CPoint dimensions = TMailerView::GetDimensions(kContracted);
  415.         VRect newFrame(0, 0, oldFrame.right, dimensions.v);
  416.         this->SetFrame(newFrame, kInvalidate);
  417.         
  418.         OSErr err = SMPExpandOrContract(this->GetGrafPort(), kContracted);
  419.         
  420.         // Move other views up
  421.         long vOffset = newFrame.GetLength(vSel) - oldFrame.GetLength(vSel);
  422.  
  423.         this->fMailerExpanded = FALSE;
  424.         fLetter->MakeRoomForMailer(vOffset, kRedraw);
  425.         
  426.         if (this->IsTarget() && this->ResignTarget())
  427.         {
  428.             this->fWantsToBeTarget = FALSE;
  429.             TWindow *theWindow = this->GetWindow();
  430.             if (theWindow && theWindow->GetWindowTarget() == this)
  431.                 theWindow->SetWindowTarget(NULL);
  432.         }
  433.     }
  434. }
  435.  
  436. //----------------------------------------------------------------------------------------
  437. // TMailerView::GetDimensions : returns the size of the mailer in its contracted or
  438. // expanded state.
  439. //----------------------------------------------------------------------------------------
  440. #pragma segment AMailerRes
  441.  
  442. CPoint TMailerView::GetDimensions(Boolean expanded)
  443. {
  444.     CPoint dimensions;
  445.     short contHeight;
  446.     short expHeight;
  447.     FailOSErr(SMPGetDimensions(&dimensions.h, &contHeight, &expHeight));
  448.     
  449.     dimensions.v = expanded ? expHeight : contHeight;
  450.     return dimensions;
  451. }
  452.  
  453. //----------------------------------------------------------------------------------------
  454. // TMailerView::DoSetupMenus : Handles the Edit Menu Items based on status of the mailer.
  455. //----------------------------------------------------------------------------------------
  456. #pragma segment AMailerRes
  457.  
  458. void TMailerView::DoSetupMenus()
  459. {
  460.     Inherited::DoSetupMenus();
  461.     WindowRef theWindow = this->GetWindow()->fWMgrWindow;
  462.     SMPMailerState theMailerState;
  463.     FailOSErr(SMPGetMailerState((WindowPtr)theWindow, &theMailerState));
  464.     Enable(cForward, theMailerState.hasBeenReceived);
  465.     Enable(cReply, theMailerState.hasBeenReceived);
  466.     if (fMailerExpanded)
  467.     {
  468.         Boolean isTarget = theMailerState.isTarget;
  469.         Enable(cClear, isTarget & theMailerState.canClear);
  470.         Enable(cCopy, isTarget & theMailerState.canCopy);
  471.         Enable(cPaste, isTarget & theMailerState.canPaste);
  472.         Enable(cSelectAll, isTarget & theMailerState.canSelectAll);
  473.         Enable(cCut, isTarget & theMailerState.canCut);
  474.         Boolean canUndo = theMailerState.undoState == kSMPMailerUndo;
  475.         Enable(cUndo, isTarget & canUndo);
  476.         if (canUndo)
  477.         {
  478.             CStr255 newCmdName = theMailerState.undoWhat;
  479.             SetCommandName(cUndo, newCmdName);
  480.         }
  481.     }
  482. }
  483.  
  484. //----------------------------------------------------------------------------------------
  485. // TMailerView::DoMenuCommand : Handles the edit menu items for the mailer.
  486. //----------------------------------------------------------------------------------------
  487. #pragma segment AMailerRes
  488.  
  489. void TMailerView::DoMenuCommand(CommandNumber aCommandNumber)
  490. {
  491.     const SMPEditCommand kSMPNoCommand = 65535;
  492.     SMPEditCommand command = kSMPNoCommand;
  493.     SMPMailerResult whatHappened = 0;
  494.     if (fMailerExpanded)
  495.     {
  496.         switch (aCommandNumber)
  497.         {
  498.             case cUndo:
  499.                 command = kSMPUndoCommand;
  500.                 break;
  501.             case cCut:
  502.                 command = kSMPCutCommand;
  503.                 break;
  504.             case cCopy:
  505.                 command = kSMPCopyCommand;
  506.                 break;
  507.             case cPaste:
  508.                 command = kSMPPasteCommand;
  509.                 break;
  510.             case cClear:
  511.                 command = kSMPClearCommand;
  512.                 break;
  513.             case cSelectAll:
  514.                 command = kSMPSelectAllCommand;
  515.                 break;
  516.         }
  517.     }
  518.     WindowRef theWindow = this->GetWindow()->fWMgrWindow;
  519.     if (command != kSMPNoCommand)
  520.     {
  521.         FailOSErr(SMPMailerEditCommand((WindowPtr)theWindow, command, &whatHappened));
  522.         if (whatHappened & kSMPAppMustHandleEventBit)
  523.             Inherited::DoMenuCommand(aCommandNumber);
  524.     }
  525.     else
  526.         Inherited::DoMenuCommand(aCommandNumber);
  527. }
  528.  
  529. //----------------------------------------------------------------------------------------
  530. // TMailerView::DoMailerEvent : Handles mouse and keyboard events for the mailer. 
  531. // Other events are handled in MMailing::DoMailerEvent.
  532. //----------------------------------------------------------------------------------------
  533. #pragma segment AMailerRes
  534.  
  535. void TMailerView::DoMailerEvent(TToolboxEvent* event)
  536. {
  537.     TWindow         *theWindow = this->GetWindow();
  538.     EventRecord     theEvent = event->fEventRecord;
  539.     SMPMailerResult whatHappened = 0;
  540.     
  541.     OSErr eventErr = SMPMailerEvent(&theEvent, &whatHappened, gFrontWindowUPP, (long)this);
  542.     if (eventErr != kSMPAddressAlreadyInList)    // ignore duplicate address error
  543.     {
  544.         FailOSErr(eventErr);
  545.         
  546.         if (whatHappened & kSMPExpandedMask)
  547.             this->ExpandMailer();
  548.         if (whatHappened & kSMPContractedMask)
  549.             this->ContractMailer();
  550.         if ((whatHappened & kSMPCreateCopyWindowMask) || (whatHappened & kSMPDisposeCopyWindowMask))
  551.             InvalidateMenuBar();
  552.     }
  553.     
  554.     if (!this->IsTarget() && (whatHappened & kSMPMailerBecomesTargetMask))
  555.     {
  556.         this->fWantsToBeTarget = TRUE;
  557.         gDispatcher->SetTarget(this);
  558.     }
  559. }
  560.  
  561. //----------------------------------------------------------------------------------------
  562. // TMailerView::DoKeyEvent
  563. //----------------------------------------------------------------------------------------
  564. #pragma segment AMailerRes
  565.  
  566. void TMailerView::DoKeyEvent(TToolboxEvent* event)
  567. {
  568.      Inherited::DoKeyEvent(event);
  569.     this->DoMailerEvent(event);
  570. }
  571.  
  572. //----------------------------------------------------------------------------------------
  573. // TMailerView::DoKeyUp
  574. //----------------------------------------------------------------------------------------
  575. #pragma segment AMailerRes
  576.  
  577. void TMailerView::DoKeyUp(TToolboxEvent* event)
  578. {
  579.     this->DoMailerEvent(event);
  580.     Inherited::DoKeyUp(event);
  581. }
  582.  
  583. //----------------------------------------------------------------------------------------
  584. // TMailerView::DoMouseCommand
  585. //----------------------------------------------------------------------------------------
  586. #pragma segment AMailerRes
  587.  
  588. void TMailerView::DoMouseCommand(VPoint& theMouse,
  589.                                  TToolboxEvent* event,
  590.                                  CPoint hysteresis)
  591. {
  592.     this->DoMailerEvent(event);
  593.     Inherited::DoMouseCommand(theMouse, event, hysteresis);
  594. }
  595.  
  596. //----------------------------------------------------------------------------------------
  597. // TMailerView::DoMouseUp
  598. //----------------------------------------------------------------------------------------
  599. #pragma segment AMailerRes
  600.  
  601. void TMailerView::DoMouseUp(VPoint& theMouse,
  602.                             TToolboxEvent* event,
  603.                             CPoint hysteresis)
  604. {
  605.     this->DoMailerEvent(event);
  606.     Inherited::DoMouseUp(theMouse, event, hysteresis);
  607. }
  608.  
  609. //----------------------------------------------------------------------------------------
  610. // TMailerView::InvalidateFrameDifference: 
  611. //----------------------------------------------------------------------------------------
  612. #pragma segment MAViewNonRes
  613.  
  614. void TMailerView::InvalidateFrameDifference(const VRect& oldFrame,
  615.                                             const VRect& newFrame)
  616. {
  617.         // Override to adjust frame for extra pixel that PowerTalk draws for 3d
  618.         // hiliting
  619.     VRect adjustedFrame = oldFrame;
  620.     adjustedFrame.right -= 1;
  621.     Inherited::InvalidateFrameDifference(adjustedFrame, newFrame);
  622. }
  623.  
  624. //----------------------------------------------------------------------------------------
  625. //  TMailerView::WantsToBeTarget
  626. //----------------------------------------------------------------------------------------
  627. #pragma segment MAViewNonRes
  628.  
  629. Boolean TMailerView::WantsToBeTarget()    // Override 
  630. {
  631.     return (fWantsToBeTarget && fMailerExpanded);
  632. } //TMailerView::WantsToBeTarget 
  633.  
  634. //----------------------------------------------------------------------------------------
  635. //  TMailerView::WantsToBeTabTarget
  636. //----------------------------------------------------------------------------------------
  637. #pragma segment MAViewNonRes
  638.  
  639. Boolean TMailerView::WantsToBeTabTarget()    // Override 
  640. {
  641.     return fMailerExpanded;
  642. } //TMailerView::WantsToBeTabTarget 
  643.  
  644. //========================================================================================
  645. // CLASS TLetterTabber
  646. //========================================================================================
  647. #undef Inherited
  648. #define Inherited TViewTabber
  649.  
  650. #pragma segment MAOpen
  651. MA_DEFINE_CLASS_M1(TLetterTabber, Inherited);
  652.  
  653. //----------------------------------------------------------------------------------------
  654. // TLetterTabber::TLetterTabber: Empty constructor to satisfy the compiler.
  655. //----------------------------------------------------------------------------------------
  656. #pragma segment ConstructorRes
  657.  
  658. TLetterTabber::TLetterTabber()
  659.     : TViewTabber(),
  660.       fLetter(NULL)
  661. {
  662. } // TLetterTabber::TLetterTabber
  663.  
  664. //----------------------------------------------------------------------------------------
  665. // TLetterTabber destructor
  666. //----------------------------------------------------------------------------------------
  667. #pragma segment MADestructorRes
  668.  
  669. TLetterTabber::~TLetterTabber()
  670. {
  671. }
  672.  
  673. //----------------------------------------------------------------------------------------
  674. // TLetterTabber::IMailWindowTabber: 
  675. //----------------------------------------------------------------------------------------
  676. #pragma segment MAOpen
  677.  
  678. void TLetterTabber::ILetterTabber(Boolean     recursive,
  679.                                   TLetter    *itsLetter)
  680. {    
  681.     fLetter = itsLetter;
  682.     this->IViewTabber(recursive);
  683. } // TViewTabber::IMailWindowTabber 
  684.  
  685. //----------------------------------------------------------------------------------------
  686. // TLetterTabber::FindSubViewTargets: 
  687. //----------------------------------------------------------------------------------------
  688. #pragma segment MATabBehaviorRes
  689.  
  690. void TLetterTabber::FindSubViewTargets(TView*     parent,
  691.                                        Boolean     tabBackward)
  692. {
  693.     TMailerView *mailerView = fLetter->GetMailerView();
  694.     Boolean mailerIsTarget = mailerView->IsTarget();
  695.     Boolean    optionIsDown = IsOptionKeyDown();
  696.         
  697.     CSubViewIterator iter(parent,!tabBackward);
  698.     
  699.     for (TView* aView = iter.FirstSubView(); iter.More(); aView = iter.NextSubView())
  700.     {
  701.         Boolean canBeTarget;
  702.         
  703.         if (aView == mailerView)
  704.             canBeTarget = aView->IsEnabled() && aView->IsShown() && mailerView->WantsToBeTabTarget(); 
  705.         else
  706.             canBeTarget = aView->IsEnabled() && aView->IsShown() && aView->WantsToBeTarget();
  707.         
  708.         if (canBeTarget && (optionIsDown != (mailerIsTarget != (aView == mailerView))))
  709.             canBeTarget = FALSE;
  710.         
  711.         if ((fFirst == NULL) && canBeTarget)
  712.             fFirst = aView;
  713.         
  714.         if (aView->IsTarget())
  715.             fFoundCurrent = TRUE;
  716.         else if (fFoundCurrent && (fNext == NULL) && canBeTarget)
  717.         {
  718.                fNext = aView;
  719.             return;
  720.         }
  721.  
  722.         if (fRecursive)
  723.             this->FindSubViewTargets(aView,tabBackward);
  724.    }
  725. } // TLetterTabber::FindSubViewTargets 
  726.  
  727. #endif // qPowerTalk
  728.  
  729. //----------------------------------------------------------------------------------------
  730. // End of UMailerView.cp
  731.  
  732. #pragma segment Inline
  733.